public class Solution {
    public int maxArea(int[] height) {
        int maxSum = 0;

        int left = 0, right = height.length - 1;
        while(left < right){
            maxSum = Math.max(Math.min(height[left], height[right]) * (right -left), maxSum);
            if(height[left] < height[right]){
                left++;
            } else {
                right--;
            }
        }

        return maxSum;
    }
}
